/*
 * Filename    : State_Logo.java
 * Projectname : RamaShinta
 * Date        : Nov 17, 2012 , 12:10:35 PM 
 * 
 * State_logo always be Sub Class NEVER Will BE SUPERCLASS
 */

package com.amikomgamedev.ramashinta.state;

import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
import org.andengine.util.color.Color;

public class State_Logo extends State_Menu_Option
{
	private boolean	isLoading	= false;

	@Override
	protected void onCreateResources()
	{
		super.onCreateResources();
		graphic.loadLogo();
	}

	@Override
	protected Scene onCreateScene()
	{
		m_Scene.setBackground(new Background(Color.WHITE));

		graphic.attachLogo();

		switchState(STATE_LOGO);
		return super.onCreateScene();
	}

	@Override
	public void onUpdate(float pSecondsElapsed)
	{
		if (State_Menu_Current == STATE_LOGO)
		{
			if (graphic.spr_Logo.hasParent() && !isLoading)
			{
				isLoading = true;

				// graphic.loadMenuBg();
				// graphic.loadButtonMenu();
				graphic.loadMenu();
				graphic.loadCreditBg();
				graphic.loadHelpBg();
				graphic.loadLoadingBg();
				graphic.loadMenuLevel();
				graphic.loadGamePlay();
				graphic.loadMenuPause();
				graphic.loadStateWin();
				graphic.loadStateLose();
				graphic.loadStateHelp();

				text.loadFontbig();
				text.loadFontMedium();
				text.loadFontSmall();
				text.loadFontCandybig();
				text.loadFontCandyMedium();
				text.loadFontCandySmall();
				sound.loadMenuBgm();
				sound.loadGameplayBgm();
				sound.loadSoundGameplay();

			}

			if (graphic.tex_Menu_Bg.isLoadedToHardware())
			{
				graphic.detachLogo();

				switchState(STATE_LOADING_SCREEN);
			}

		}
		super.onUpdate(pSecondsElapsed);
	}

	@Override
	protected void switchState(byte state)
	{

		super.switchState(state);

		State_Menu_Current = state;

		switch (state)
		{
			case STATE_LOGO:

				break;

			case STATE_LOADING_SCREEN:
				create_State_Loading_Screen();
				break;

			case STATE_MENU_MAIN:
				create_Menu_Main();
				break;

			case STATE_MENU_LEVEL:
				create_Menu_Level();
				break;

			case STATE_MENU_CREDIT:
				create_Menu_Credit();
				break;

			case STATE_MENU_HELP:
				create_State_Menu_Help();
				break;

			case STATE_MENU_OPTION:
				create_State_Menu_Option();
				break;

			case STATE_GAME_PLAY:
				create_State_Game_Play();
				break;

			case STATE_GAME_WIN:
				create_State_Game_Win();
				break;

			case STATE_GAME_PAUSE:
				create_State_Game_Pause();
				break;

			case STATE_GAME_OVER:
				create_State_Game_Over();
				break;

		}
	}
}
